﻿using System;
using jQueryDemo.Class;
using System.Web.Services;
using jQueryDemo.BusinessObject.Entity;
using System.Collections.Generic;
using System.Web.Script.Serialization;

namespace jQueryDemo
{
    public partial class AJAX : PageBase
    {
        protected override void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);
        }

        /// <summary>
        /// Check client name
        /// </summary>
        /// <param name="fname"></param>
        /// <param name="lname"></param>
        /// <returns></returns>
        [WebMethod]
        public static string CheckClientName(string fname, string lname)
        {
            string result = string.Empty;
            
            //Database call
            Client client = (new Client()).CheckClientAvailability(fname, lname);

            //JSON serialisation
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            result = serializer.Serialize(client);

            return result;
        }
    }
}